/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.concurrent.TimeUnit;

/**
 * <p>Project: app2022 - T29
 * <p>Powered by webrx On 2022-02-08 09:40:38
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class T29 {
    volatile boolean running = true;

    public static void main(String[] args) {
        var t = new T29();
        new Thread(t::m, "t1").start();
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //main线程修改了running 值
        t.running = false;
        System.out.println(t.running);
    }

    void m() {
        System.out.println("m start");
        while (running) {
			/*
			try {
				TimeUnit.MILLISECONDS.sleep(10);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}*/
        }
        System.out.println("m end!");
    }
}
